<!-- 订单确认详情 -->
<script>
import bus from "@/eventBus";
import InterviewDetailLeftNav from "@/components/detailCommons/interviewDetailLeftNav";
import InterviewDetailCandidate from "@/components/detailCommons/interviewDetailCandidate";
import InterviewDetailDemand from "@/components/DemandDetail";
import InterviewDetailChat from "@/components/detailCommons/interviewDetailChat";
import InterviewDetailVia from "@/components/detailCommons/interviewDetailVia";
import InterviewDetailNotGo from "@/components/detailCommons/interviewDetailNotGo";
import InterviewDetailPriceTableInp from "@/components/detailCommons/interviewDetailPriceInpTable";
import QuotePrices from "./components/quotePrices";
import InterviewCourse from "@/components/interviewCourses/interviewCourse";
import { decCourses } from "@/decs/dec_interviewCourse";
import { dec_demandDetail } from "@/decs/dec_interviewDemandDetail";
import InterviewTimeCourse from "@/components/interviewCourses/InterviewTimeCourse";
function fetchQuotedDetialInfo(store, opts) {
  return store.dispatch("FETCH_QUOTED_DETAIL", opts);
}

export default {
  components: {
    InterviewDetailCandidate,
    InterviewDetailDemand,
    InterviewDetailLeftNav,
    InterviewDetailChat,
    InterviewDetailNotGo,
    InterviewDetailVia,
    InterviewCourse,
    InterviewDetailPriceTableInp,
    QuotePrices,
    InterviewTimeCourse
  },
  data() {
    return {
      componentName: "InterviewDetailPriceTableInp",
      userInfo: {
        // * 人员信息
        name: "",
        ex: "",
        fileUrl: "",
        zz: "",
      },
      navs: [
        // * 左侧选项对象
        {
          lable: "结算方式",
          id: "4",
          val: "InterviewDetailPriceTableInp",
          isActive: true,
        },
        {
          lable: "简历进展概况",
          id: "1",
          val: "InterviewCourse",
          isActive: false,
        },
        {
          lable: "候选人信息",
          id: "2",
          val: "InterviewDetailCandidate",
          isActive: false,
        },
        {
          lable: "需求详情",
          id: "3",
          val: "InterviewDetailDemand",
          isActive: false,
        },
        {
          lable: "面试时间进程",
          id: "4",
          val: "InterviewTimeCourse",
          isActive: false,
        },
      ],
      clearingForm: {
        // * 结算名称公式
        postName: "",
        rankLevel: "",
        positionPrice: "",
        settName: "",
        settDetail: "",
      },
      scaleDatas: {
        // * 结算方式对象
        isFeedBack: true,
        datas: [],
        isBuildPrice: false,
        allWorkTxt: "", // * 全勤显示文本
        otherWorkTxt: "", // * 缺勤显示文本
        allWorkVal: "", // * 全勤下拉框值
        otherWorkVal: "", // * 缺勤下拉框值
      },
      candidateData: {
        // * 候选人信息
        name: "",
        record: "",
        handsOn: "",
        isInJob: "",
        comeTime: "",
        phone: "",
        desc: "",
      },
      demandData: {
        // * 需求详情
        jobName: "",
        jobType: "",
        moenyType: "",
        reportsTo: "",
        quantity: "",
        workingDeadline: "",
        workYears: "",
        jobAddress: "",
        budget: "",
        supplier: "",
        inJobTime: "",
        publishTime: "",
        jobDesc: "",
        jobAsk: "",
        needsCode: "",
        pathO: "",
        pathT: "",
        pathS: "",
        needsNumber: "",
      },
      courseInfos: [], // * 简历历程
      state: "", // * 数据状态
    };
  },
  created() {
    this.getQueryData();
  },
  mounted() {
    bus.$on("select-tab", this.selectTabItem);
  },
  methods: {
    // * 获取路由参数值
    getQueryData() {
      let id = this.$route.params.id;
      const { stus, ot } = this.$route.query;
      this.state = stus;
      this.fetchDetailData(id, ot);
    },
    // * 获取详情数据
    async fetchDetailData(needsCvId, offerType) {
      await fetchQuotedDetialInfo(this.$store, { needsCvId });
      const { state, data } = this.$store.getters.getQuotedDetailInfo;
      if (state === "0000") {
        const {
          cvdbInfo,
          needsDetails,
          depts,
          cvdbCourse,
          clearingForm,
        } = data;

        // * 结算方式
        this.clearingForm = clearingForm;

        // 候选人简历信息
        this.candidateData = {
          name: cvdbInfo.surname,
          record: cvdbInfo.education_code,
          handsOn: cvdbInfo.work_experience,
          isInJob: cvdbInfo.current_status_code,
          comeTime: cvdbInfo.post_time,
          phone: cvdbInfo.telephone,
          desc: cvdbInfo.reason,
        };
        // 需求详情
        this.demandData = dec_demandDetail(needsDetails, "", "", "", depts);

        // 候选人信息
        this.userInfo.name = this.candidateData.name;
        this.userInfo.ex = this.demandData.postCode;
        this.userInfo.zz = cvdbInfo.file_url;
        this.userInfo.cvdbId = cvdbInfo.id; // 文件ID
        this.userInfo.fileName = cvdbInfo.fileName;
        // 简历进展历程

        this.courseInfos = decCourses(cvdbCourse);
        console.log('this.courseInfos---------------------')
        console.log(this.courseInfos) 
      }
    },
    // * 切换左侧选项
    selectTabItem(type) {
      if (!type) {
        this.componentName = "InterviewDetailPriceTableInp";
        return;
      }
      this.componentName = type;
    },
  },
  beforeDestroy() {
    bus.$off("select-tab", this.selectTabItem);
  },
};
</script>

<template>
  <ul class="interview-common-detail">
    <li class="resume-detail-left">
      <InterviewDetailLeftNav
        :userInfo="userInfo"
        :navs="navs"
      ></InterviewDetailLeftNav>
    </li>
    <li class="resume-detail-right">
      <backButton :backPath="'/quoted'"></backButton>
      <component
        :is="componentName"
        :tip-text="'审批意见'"
        :clearingForm="clearingForm"
        :scaleDatas="scaleDatas"
        :course-infos="courseInfos"
        :candidateInfo="candidateData"
        :textDatas="demandData"
        :isShowInterviewBox="false"
      ></component>
    </li>
  </ul>
</template>

<style lang="scss">
@import "~@/assets/scss/mixins.scss";
@include Interview-detail;
</style>
